﻿using System;
using System.Collections.Generic;
using System.Text;
using rkShared.Serialization;

namespace rkShared
{
	public class Billboard:IBinarySerializable
	{
		public Billboard(rkShared.Vector3 position,float size,float tile,float totalTiles,bool hit)
		{
			this.size = size;
			this.position.Copy(position);
			this.fTile = tile;
			this.fTotal = totalTiles;
            this.hit = hit;

		}
        public Billboard()
        {
        }
		public float size = 20.0f;
		public rkShared.Vector3 position = new rkShared.Vector3();
        public bool hit = false;


		public float fTile = 0.0f;
		public float fTotal = 10.0f;



        #region IBinarySerializable Members

        public void SerializeToDictionary(rkShared.BEncode.BEncodedDictionary dictionary)
        {
            dictionary.Add("s", size.ToString());
            dictionary.Add("ti", fTile.ToString());
            dictionary.Add("to", fTotal.ToString());
            dictionary.Add("p", position);
            dictionary.Add("h", hit ? 1 : 0);
        }

        public void DeserializeFromDictionary(rkShared.BEncode.BEncodedDictionary dict)
        {
            size = float.Parse(dict.GetString("s"));
            fTile = float.Parse(dict.GetString("ti"));
            fTotal = float.Parse(dict.GetString("to"));
            position = dict.GetIBinarySerializable<Vector3>("p");
            this.hit = dict.GetInt("h") == 1;
        }

        #endregion
    }
}
